//
//  CSGXBubbleView.m
//  CarSalesMS_GCX
//
//  Created by Ssky on 2016/12/6.
//  Copyright © 2016年 Tony. All rights reserved.
//

#import "CSGXBubbleView.h"

@interface CSGXBubbleView ()

@property (nonatomic, strong) UILabel *lblTitle;


@end

@implementation CSGXBubbleView
@synthesize color = _color;

+ (instancetype)bubbleView {
    id obj = [[self alloc] init];
    return obj;
}

- (void)drawRect:(CGRect)rect {
    //
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:self.bounds];
    
    [path addClip];
    
    [self.color setFill];
    
    [path fill];
}


#pragma mark - methods


#pragma mark - setter & getter
- (void)setColor:(UIColor *)color {
    _color = !color ? [UIColor orangeColor] : color;
    
    [self setNeedsDisplay];
}

- (UIColor *)color {
    if (!_color) {
        _color = [UIColor orangeColor];
    }
    return _color;
}

- (void)setNumberStr:(NSString *)numberStr {
    _numberStr = numberStr.copy;
    self.backgroundColor = [UIColor clearColor];
    self.lblTitle.text = _numberStr;
}

- (UILabel *)lblTitle {
    if (!_lblTitle) {
        _lblTitle = [[UILabel alloc] initWithFrame:self.bounds];
        
        _lblTitle.textColor = [UIColor whiteColor];
        _lblTitle.font = [UIFont boldSystemFontOfSize:11];
        _lblTitle.textAlignment = NSTextAlignmentCenter;
        
        [self addSubview:_lblTitle];
    }
    return _lblTitle;
}




@end
